/*
 * @Author: Wxx
 * @Date: 2022-03-01 17:02:15
 * @LastEditors: Wxx
 * @LastEditTime: 2022-03-01 17:09:21
 * @Description:
 */
import React, { Component, memo } from "react";

/**
 * memo 用于函数组件的性能优化 pureComponent用于class组件性能优化
 * 当props没有更新时 不会在重新渲染子组件 提升性能
 */
export default class App extends Component {
  state = {
    name: "bj",
    title: "hhh",
  };

  render() {
    return (
      <div>
        <button
          onClick={() => {
            this.setState({
              name: "wb",
            });
          }}
        >
          改变名字
        </button>
        <button
          onClick={() => {
            this.setState({
              title: "新标题",
            });
          }}
        >
          改变标题
        </button>
        <Child title={this.state.title} />
      </div>
    );
  }
}
const Child = memo((props) => {
  console.log("child打晕吧");
  return <div>Child-{props.title}</div>;
});
